const sequelize = require('../config/database')

async function showUsers() {
  try {
    console.log('尝试连接数据库...')
    await sequelize.authenticate()
    console.log('数据库连接成功')
    console.log('查询users表结构...')
    const [results] = await sequelize.query('DESCRIBE users')
    console.log('users表结构:')
    if (results && results.length > 0) {
      results.forEach((field) => {
        console.log(
          `字段: ${field.Field}, 类型: ${field.Type}, 可空: ${field.Null}, 主键: ${field.Key}, 默认值: ${field.Default}`
        )
      })
    } else {
      console.log('无法获取users表结构信息')
    }
  } catch (error) {
    console.error('操作失败:', error)
  } finally {
    console.log('脚本执行完毕')
    process.exit(0)
  }
}

showUsers()
